package cn.xopencode.oss.rpc.passport;
import cn.xopencode.oss.manager.passport.PassportManager;
import cn.xopencode.oss.rpc.passport.vo.*;
import cn.xopencode.common.framework.vo.CommonResult;

import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.beans.factory.annotation.Autowired;

import static cn.xopencode.common.framework.vo.CommonResult.success;
@DubboService(version = "${dubbo.provider.PassPortRpc.version}")
public class PassportRpcImpl implements PassPortRpc{
    @Autowired
    private PassportManager passportManager;
    @Override
    public CommonResult<PassportAccessTokenRespVO>  loginByMobile(PassportLoginByMobileReqVO loginByMobileDTO, String ip) {
        return success(passportManager.loginByMobile(loginByMobileDTO,ip),"手机号为"+loginByMobileDTO.getMobile()+"的用户登录成功。");
    }
    @Override
    public CommonResult<PassportAccessTokenRespVO> loginByUserName(PassportLoginByUserNameReqVO loginByUseNameDTO, String ip) {
        return success(passportManager.loginByUserName(loginByUseNameDTO,ip),"用户名为"+loginByUseNameDTO.getUsername()+"的用户登录成功。");
    }
    @Override
    public CommonResult<PassportAccessTokenRespVO>  loginBySms(PassportLoginBySmsReqVO loginBySmsDTO, String ip) {
        return success(passportManager.loginBySms(loginBySmsDTO,ip),"手机号为"+loginBySmsDTO.getMobile()+"的用户登录成功。");
    }
    @Override
    public CommonResult<Boolean> sendSmsCode(PassportSendSmsRespVO sendSmsCodeDTO, String ip) {
        passportManager.sendSmsCode(sendSmsCodeDTO, ip);
        return success(true);
    }
    @Override
    public  CommonResult<PassportAccessTokenRespVO> refreshToken(String refreshToken, String ip) {
         return success(passportManager.refreshToken(refreshToken,ip));

    }
}
